﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PEUtils
{
    public enum LoggerType
    {
        Unity,
        Console,

    }
    public enum LogColor
    {
        None = 0,
        Red = 1,
        Orange = 2,
        Yellow = 3,
        Green = 4,
        Cyan = 5,
        Blue = 6,
        Magenta = 7,
        Gray = 8
    }

    //日志的配置信息
    public class LogConfig
    {
        // 是否启用
        public bool enableLog = true;
        // 日志前缀
        public string logPrefix = "#";
        // 启用时间
        public bool enableTime = true;
        // 间隔符号
        public string logSeparate = ">>";
        // 线程ID
        public bool enableThreadID = true;
        // 堆栈信息
        public bool enableTrace = true;
        // 保存文件
        public bool enableSave = true;
        // 日志覆盖
        public bool enableCover = true;
        // 日志储存地址
        private string _savePath;
        public string savePath
        {
            get
            {
                if (_savePath == null)
                {
                    if (loggerType == LoggerType.Unity)
                    {
                        //反射
                        Type type = Type.GetType("UnityEngine.Application, UnityEngine");
                        _savePath = type.GetProperty("persistentDataPath").GetValue(null).ToString() + "/PELog/";
                    }
                    else
                    {
                        _savePath = $"{AppDomain.CurrentDomain.BaseDirectory}Logs\\";
                    }
                }
                return _savePath;
            }
            set
            {
                _savePath = value;
            }
        }
        // 日志文件名
        public string saveName = "ConsolePELog.txt";
        // 日志输出器类型
        public LoggerType loggerType = LoggerType.Console;
        // TODO
        public Action<int> GetFrameIndex;
    }
}
